<template>
	<view style="height: 100%">
		<view class="head">
			<view class="item" :class="itemActive==0?'active':'ZW'" @click="itemBtn(0)">当前订单</view>
			<view class="item" :class="itemActive==1?'active':'ZW'" @click="itemBtn(1)">历史订单</view>
		</view>
		<view class="content">
			<view class="item" v-if="itemActive==0?true:false">
				<view class="order_hint" v-if="ifShow">
					<image src="../../../../static/image/order_hint.png"></image>
					<view>您还没有相关的订单</view>
				</view>
				<view class="it" v-for="(item, index) in myorderList" :key="index">
					<view class="it-hd">
						<view class="left">住家月子服务({{item.days}}天)</view>
						<view class="right">全额: ￥{{item.payable_price}}元</view>
					</view>
					<view class="it-bd">
						<view class="headImg">
							<image :src="item.avatar_url" mode=""></image>
						</view>
						<view class="right">
							<view class="userName">{{item.name}}</view>
							<view class="address">地址: {{item.address}}</view>
							<view class="mobile">联系电话: {{item.mobile}}</view>
							<view class="time">预约时间: {{item.start_time}}</view>
						</view>
						<view class="status">正在进行..</view>
					</view>
				</view>
			</view>
			<view class="item" v-if="itemActive==1?true:false">
				<view class="order_hint" v-if="ifShow">
					<image src="../../../../static/image/order_hint.png"></image>
					<view>您还没有相关的订单</view>
				</view>
				<view class="it" v-for="(item, index) in myorderList" :key="index">
					<view class="it-hd">
						<view class="left">住家月子服务({{item.days}}天)</view>
						<view class="right">全额: ￥{{item.payable_price}}元</view>
					</view>
					<view class="it-bd">
						<view class="headImg">
							<image :src="item.avatar_url" mode=""></image>
						</view>
						<view class="right">
							<view class="userName">{{item.name}}</view>
							<view class="address">地址: {{item.address}}</view>
							<view class="mobile">联系电话: {{item.mobile}}</view>
							<view class="time">预约时间: {{item.start_time}}</view>
						</view>
						<button class="getPrice" :class="item.is_receive == 0 ? 'ZW' : 'active'" @click="openincome" :disabled="item.is_receive == 0 ? false : true">{{item.is_receive == 0 ? '领取佣金' : '已领取'}}</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {dns} from "@/pages/dns.js";
	export default {
		data(){
			return {
				ifShow: false,
				itemActive: 0,
				myorderList: []
			}
		},
		onLoad() {
			this.getorderList(0)
		},
		methods:{
			itemBtn(num){
				this.itemActive = num;
				this.getorderList(num)
			},
			getorderList(status){
				uni.request({
					method: 'GET',
					data: {
						status
					},
					header:{
						token: uni.getStorageSync("token")
					},
					url: dns + 'order/matron_list',
					success: (res)=>{
						console.log(res)
						if(res.data.status == -1){
							uni.showToast({
								icon: 'none',
								title: res.data.msg
							})
							this.ifShow = true;
							return;
						}
						if(res.data.status == 1){
							this.myorderList = res.data.data;
							this.ifShow = false;
						}
						if(res.data.data.length == 0){
							this.myorderList = [];
							this.ifShow = true;
						}
					}
				})
			},
			openincome(){//进入我的收入
				// uni.navigateTo({
				// 	url: '../myincome/index'
				// })
				uni.showModal({
				    title: '如何领取?',
				    content: '请前往最近的平台门店领取佣金!',
					showCancel: false,
					confirmColor: '#ff5c5d',
				    success: function (res) {
				        if (res.confirm) {
				            // console.log('用户点击确定');
				        }
				    }
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f6f6f6;
		height: 100%;
	}
	.head{
		display: flex;
		background-color: #f6f6f6;
		position: fixed;
		width: 100%;
		z-index: 999;
		top: 0;
		left: 0;
		.item{
			line-height: 76upx;
			width: 50%;
			text-align: center;
			color: #000;
			font-size: 28upx;
		}
		.item.active{
			color: #ff5c5d;
		}
		.item.active::after{
			content: '';
			display: block;
			height: 4upx;
			width: 70upx;
			margin: 0 auto;
			margin-top: -4upx;
			background-color: #ff5c5d;
		}
	}
	.content{
		height: 100%;
		background-color: #f6f6f6;
		padding-top: 76upx;
		.item{
			position: relative;
			background-color: #f6f6f6;
			height: 100%;
			.order_hint{
				position: absolute;
				top: 40%;
				left: 50%;
				transform: translate(-50%,-50%);
				image{
					width: 400upx;
					height: 400upx;
				}
				view{
					text-align: center;
					font-size: 30upx;
					margin-top: -50upx;
				}
			}
			.it{
				padding: 20upx 40upx 30upx 40upx;
				background-color: #fff;
				margin-bottom: 15upx;
				.it-hd{
					display: flex;
					justify-content: space-between;
					margin-bottom: 20upx;
					.left{
						font-size: 28upx;
					}
					.right{
						font-size: 30upx;
					}
				}
				.it-bd{
					display: flex;
					position: relative;
					.headImg{
						width: 140upx;
						height: 140upx;
						border-radius: 50%;
						overflow: hidden;
						margin-right: 20upx;
						image{
							width: 100%;
							height: 100%;
						}
					}
					.right{
						color: #8b8b8b;
						font-size: 24upx;
						margin-bottom: 6upx;
						.userName{
							color: #000;
							font-size: 28upx;
						}
						.time{
							margin-bottom: 0;
						}
					}
					.status{
						position: absolute;
						right: 0;
						top: 0upx;
						font-size: 24upx;
						color: #ff5c5d;
					}
					.getPrice{
						position: absolute;
						bottom: 20upx;
						right: 0;
						margin: 0;
						border: none;
						width: 156upx;
						padding: 0;
						display: inline-block;
						background-color: #fff;
						font-size: 24upx;
						line-height: 52upx;
						text-align: center;
						border-radius: 30upx;
						margin-left: 20upx;
						border: 2upx solid #f3a47c;
						color: #f5984b;
					}
					.active{
						border: 2upx solid #dddddd;
						color: #7f7f7f;
					}
				}
			}
		}
	}
</style>
